<!--
 * @Author: 迷洛洛ywc
 * @Date: 2024-03-12 16:01:35
 * @LastEditors: 迷洛洛ywc
 * @LastEditTime: 2024-05-06 14:51:07
 * @Description: file content
-->
<template>
  <!-- 农事记录 -->
  <div class="block" style="height: 100%">
    <div
      class="missionList"
      v-for="item in missions"
      :key="item.index"
      @click="openEdit(item)"
    >
      <img class="landRight" src="@/assets/images/landRight.png" />
      <div class="missionInfoType">{{ item.type }}</div>
      <div class="missionInfo">
        <div class="missionTime">时间：<span>{{ item.time }}</span></div>
        <div class="missionUser">操作人：{{ item.participants }}</div>
      </div>

      <!-- 防治 -->
        <div class="farmStockList" v-if="item.code === 'NS_FZ'">
          <div
            class="farmsStock"
            v-for="agriList in item.agriList"
            :key="agriList.id"
          >
            <!-- <div class="farmsStockIcon">
              <img src="../../../assets/img/huafeiicon.png" alt="" />
            </div> -->
            <div class="farmsStockName">{{ agriList.name }}</div>
            <div class="farmsStockNum">{{ agriList.num }}公斤</div>
          </div>
        </div>
      <!-- 施肥 -->
        <div class="farmStockList" v-if="item.code === 'NS_SF'" >
      <div class="farmsStock" v-for="agriList in item.agriList" :key="agriList.id" >
          <!-- <div class="farmsStockIcon">
            <img src="../../../assets/img/huafeiicon.png" alt="" />
          </div> -->
          <div class="farmsStockName">{{ agriList.name }}</div>
          <div class="farmsStockNum">{{ agriList.num }}公斤</div>
        </div>
      </div>
      <!-- 播种 -->
      <div class="missionInfo" v-if="item.code === 'NS_BZ'">
        <div class="missionTime">品种：{{ item.seedType }} {{ item.seedInfo }}</div>
        <div class="missionTime" v-if="item.seedNum !== null">
          种子数量：{{ item.seedNum }}
        </div>
        <div class="missionTime" v-if="item.seedSpacing !== null">
          种间距：{{ item.seedSpacing }}cm
        </div>
      </div>
      <div :class="!item.agriList && 'mt10'" v-if="item.picture">
        <div
          class="missionImg"
          v-for="(pic, index) in item.picture.split(',')"
          :key="index"
          @click.stop="pictureBig(pic)"
        >
          <img :src="pic" alt="" />
        </div>
      </div>
      <div class="missionTime" v-if="item.remark">备注：{{ item.remark }}</div>
    </div>

    <el-dialog
      :visible.sync="dialogVisible"
      width="600"
      append-to-body
    >
      <img
        :src="dialogImageUrl"
        style="display: block; max-width: 100%; margin: 0 auto"
      />
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'SevencolorUserArgiMissionComponents',
  props: {
    landMissionData: {
      type: Array
    }
  },

  data () {
    return {
      missions: [],
      dialogImageUrl: '',
      dialogVisible: false,
      dialogOver: false,
      options: []
    }
  },
  computed: {
    missionDetail () {
      return this.$store.getters.missionDetail
    }
  },
  mounted () {
    this.changeData()
  },

  methods: {
    // 数据处理
    changeData () {
      // console.log(this.landMissionData)
      this.missions = this.landMissionData
      // for (let i = 0; i < this.missions.length; i++) {
      //   if (
      //     this.missions[i].picture !== '' &&
      //     this.missions[i].picture !== null &&
      //     this.missions[i].picture !== undefined
      //   ) {
      //     this.missions[i].picture = this.landMissionData[i].picture
      //       .split(',')
      //       .map((picture) => picture)
      //   } else {
      //     this.missions[i].picture = []
      //   }
      // }
      // console.log(this.missions)
    },
    // 照片放大
    pictureBig (pic) {
      this.dialogImageUrl = pic
      this.dialogVisible = true
    },
    // 详情
    openEdit (data) {
      if (data.code === 'NS_BZ') {
        this.$message('请点击作物查看播种详情')
      } else if (data.code !== 'NS_BZ') {
        this.$store.dispatch('mission/updatemissionDetail', data)
        // console.log(this.missionDetail)
        this.$router.push({
          path: '/shuzhongtian/agriMissionAdd',
          query: {
            ...this.$route.query,
            name: data.type,
            code: data.code
          }
        })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.missionList {
  // height: 16.6667vw * 0.834;
  background: #FAFAFA;
  border-radius: 4px;
  padding: 15px 20px 5px 20px;
  margin-bottom: 15px;
  position: relative;
  .landRight {
    width: 30px;
    height: 30px;
    position: absolute;
    right: 60px;
    top: 0;
    bottom: 0;
    margin: auto
  }
}
.missionList:hover {
  border: 1px solid #00C586;
}
.missionInfoType {
  // width: 8.1667vw;
  font-weight: 600;
  font-size: 20px;
  color: #333333;
  margin-bottom: 10px
}
.missionInfo {
  display: flex;
  .missionUser {
    color: #999;
    font-size: 14px;
  }
}
.missionTime {
  width: 200px;
  color: #999;
  font-size: 14px;
  margin-bottom: 10px;
  span {
    color: #00C586;
    font-weight: bold;
  }
}
.missionRemark {
  font-weight: 400;
  font-size: 1.0417vw;
  color: #666666;
  margin: 1.0417vw * 0.834 0 0.5208vw * 0.834;
}
.farmStockList {
  width: 70%;
  display: flex;
}
.farmsStock {
  margin-bottom: 10px;
  min-width: 200px;
  margin-right: 10px;
  background: #E1F5EE;
  border-radius: 4px;
  display: flex;
  padding: 5px 10px;
  justify-content: space-between;
  color: #00C586;
  font-size: 14px;
  .farmsStockIcon {
    width: 1.6667vw;
    height: 1.6667vw;
    margin: auto 1.0417vw;
  }
  .farmsStockName {
  }
  .farmsStockNum {
  }
}

.missionImg {
  margin-bottom: 10px;
  width:  80px;
  height: 80px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 15px;
  img {
    width:  80px;
    height: 80px;
  }
}
</style>
